package hibernate.mappings;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class MySessionFactory {
	private static String cf = "hibernate.cfg.xml";
	private static final Configuration c = new Configuration();
	private static SessionFactory sf;

	public static Session getSession() {
		if (sf == null) {
			try {
				c.configure(cf);
				sf = c.buildSessionFactory();
			} catch (Exception e) {
				System.err
						.println("%%%%MySessionFactory.java:   Error   Creating   SessionFactory   %%%% ");
				e.printStackTrace();
			}
		}
		return sf.openSession();
	}
	
	

}
